<admintpl file="header" />
</head>
<body class="J_scroll_fixed">
	<div class="wrap J_check_wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Event/index')}">赛事列表</a></li>
			<li><a href="{:U('Event/add')}">添加赛事</a></li>
			<li class="active"><a>修改赛事</a></li>
		</ul>
<form name="myform" id="myform" action="{:u('Event/edit_post')}" method="post" class="form-horizontal J_ajaxForm" enctype="multipart/form-data">
<div class="col-auto">
	<div class="table_full">
	  <table class="table table-bordered">
	    <tr>
	      <th>名称<input type="hidden" name="id" value="{$gameinfos.id}" /></th>
	      <td><input type="text" name="game_name" value="{$gameinfos.game_name}" class="input input_hd J_title_color"/></td>
	    </tr>
	    <tr>
	      <th>说明</th>
	      <td><textarea name='game_description1' style='height:55px;'>{$gameinfos.game_description1}</textarea></td>
	    </tr>
	    <tr>
	      <th>赛规地址</th>
	      <td><if condition="$gameinfos['rules_url']">{$gameinfos.rules_url}<else />无赛规、请在赛规页面添加或修改关联</if></td>
	    </tr>
	    <tr>
	      <th>参数人数</th>
	      <td>
			<select name="player_type" class="normal_select">
        		<foreach name="players" item="player">
		        	<if condition="$player['id'] eq $gameinfos['player_type']">
					<option value="{$player.id}" selected="selected">{$player.name}</option>
					<else />
					<option value="{$player.id}">{$player.name}</option>
        			</if>
               	</foreach>
			</select>
	      </td>
	    </tr>
	    <tr>
	      <th>比赛状态</th>
	      <td>
			<select name="status" class="normal_select">
        		<foreach name="statuss" item="status">
		        	<if condition="$status['id'] eq $gameinfos['status']">
					<option value="{$status.id}" selected="selected">{$status.name}</option>
					<else />
					<option value="{$status.id}">{$status.name}</option>
        			</if>
               	</foreach>
			</select></td>
	    </tr>
	    <tr>
	      <th>主办方</th>
	      <td><input type="text" name="host_title" value="{$gameinfos.host_title}" class="input"></td>
	    </tr>
	    <tr>
	      <th>协办方</th>
	      <td><input type="text" name="host_field" value="{$gameinfos.host_field}" class="input"></td>
	    </tr>
	    <tr>
	      <th>承办方</th>
	      <td><input type="text" name="other_partner" value="{$gameinfos.other_partner}" class="input"></td>
	    </tr>
	    <tr>
	      <th>开始时间</th>
	      <td><input type="text" name="startdate" value="{$gameinfos.startdate}" class="J_date"></td>
	    </tr>
	    <tr>
	      <th>开赛时间</th>
	      <td><input type="text" name="gamedate" value="{$gameinfos.gamedate}" class="J_date"></td>
	    </tr>
	    <tr>
	      <th>结束时间</th>
	      <td><input type="text" name="enddate" value="{$gameinfos.enddate}" class="J_date"></td>
	    </tr>
		<if condition="!$gameinfos['province'] || !$gameinfos['city'] || !$gameinfos['district']">
	    <tr>
	      <th>省-市-县</th>
	      <td>
	        <select id="province" name = "province" class="normal_select" style="width: 106px;"></select>
	        <select id="city" name = "city" class="normal_select" style="width: 106px;"></select>	
	        <select id="district" name = "district" class="normal_select" style="width: 100px;"></select>	
			<script class="resources library" src="__ROOT__/statics/js/area.js" type="text/javascript"></script>
	        <script type="text/javascript">_init_area();</script>
	      </td>
	    </tr>
        </if>
        
	    <tr>
	      <th>LOGO(图片宽必须为高的1倍)</th>
	      <td>
			<if condition="$gameinfos['game_logo']">
				<img src="{$webshowimg}{$gameinfos.game_logo}" width="108">
        	</if>
	      	<input type="file" name="game_newlogo" id="file1" multiple="multiple" accept="image/*" />
			<img src="" id="img1" width="108">
	      </td>
	    </tr>
	    <tr>
	      <th>广告(图片宽必须为高的3.4倍)</th>
	      <td>
			<if condition="$gameinfos['game_adv']">
				<img src="{$webshowimg}{$gameinfos.game_adv}" width="216">
        	</if>
	      	<input type="file" name="game_newadv" id="file2" multiple="multiple" accept="image/*"/>
			<img src="" id="img2" width="216">
	      </td>
	    </tr>
	    <tr>
	      <th>背景(图片宽必须为高的3.4倍)</th>
	      <td>
			<if condition="$gameinfos['game_bg']">
				<img src="{$webshowimg}{$gameinfos.game_bg}" width="216">
        	</if>
	      	<input type="file" name="game_newbg" id="file3" multiple="multiple" accept="image/*"/>
			<img src="" id="img3" width="216">
	      </td>
	    </tr>
	  </table>
	</div>
</div>
<div class="form-actions">
	<button class="btn btn-primary btn_submit J_ajax_submit_btn"type="submit">提交</button>
	<button type="button" class="btn" onclick="javascript:history.go(-1);">返回</button>
</div>
</form>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
		<script>	
$("#file1").change(function(){
	var objUrl = getObjectURL(this.files[0]) ;
	console.log("objUrl = "+objUrl) ;
	if (objUrl) {
		$("#img1").attr("src", objUrl) ;
	}
}) ;
$("#file2").change(function(){
	var objUrl = getObjectURL(this.files[0]) ;
	console.log("objUrl = "+objUrl) ;
	if (objUrl) {
		$("#img2").attr("src", objUrl) ;
	}
}) ;
$("#file3").change(function(){
	var objUrl = getObjectURL(this.files[0]) ;
	console.log("objUrl = "+objUrl) ;
	if (objUrl) {
		$("#img3").attr("src", objUrl) ;
	}
}) ;
//建立一個可存取到該file的url
function getObjectURL(file) {
	var url = null ; 
	if (window.createObjectURL!=undefined) { // basic
		url = window.createObjectURL(file) ;
	} else if (window.URL!=undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file) ;
	} else if (window.webkitURL!=undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file) ;
	}
	return url ;
}
</script>
</body>
</html>